<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <script>
        // 
        function random( n , min , max ){
            if(max - min + 1 > n)return;
            var arr = [];
            for(var i = 0; i<n ; i++){
                arr[i] = Math.floor(Math.random() * (max - min + 1)) + min;
                for(var j = 0; j<i; j++){
                    if(arr[j] === arr[i]){
                        i--;
                        break;
                    }
                }
            }
            return arr;
        }
        console.log(random(10,1,10));
        //
        function random1(n,min,max){
            var temp = Math.floor(Math.random()*(max - min + 1)) + min;
            var arr = [];
            function rand(){
                temp = Math.floor(Math.random()*(max - min + 1)) + min;
                if(arr.indexOf(temp)===-1){
                    return temp;
                }else {
                    return rand();
                }
            }
            for(var i = 0;i<n ; i++){
                arr.push(rand());
            }
            return arr;
        }
        console.log(random1(10,1,10));
    </script>
</body>
</html>